home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Celestin Apprentice 5
/
Apprentice-Release5.iso
/
Source Code
/
C++
/
Applications
/
PICSee Dust 1.01
/
Quaternary Source
/
CP_Utils.h
< prev
next >
Wrap
Text File
|
1995-11-24
|
2KB
|
73 lines
#ifndef CP_UTILS_H_
#define CP_UTILS_H_
#ifndef CP_DATA_H_
#include "CP_Data.h"
#endif
// ---------------------------------------------------------------------------
#ifdef __cplusplus
extern "C" {
#endif
void CP_SetRect(CP_Rect *destR, CP_Long left, CP_Long top, CP_Long right, CP_Long bottom);
void CP_OffsetRect(CP_Rect *destR, CP_Long offsetH, CP_Long offsetV);
void CP_UnionRect(const CP_Rect *rectA, const CP_Rect *rectB, CP_Rect *unionR);
void CP_CenterRect(CP_Rect *innerRect, const CP_Rect *outerRect);
void CP_MoveRectTo(CP_Rect *theRect, CP_Long destLeft, CP_Long destTop);
void CP_OffsetPoint(CP_Point *pt, CP_Long offsetH, CP_Long offsetV);
short CP_PointInRect(const CP_Point *pt, const CP_Rect *rect);
#ifdef __cplusplus
}
#endif
// ---------------------------------------------------------------------------
/*
Some useful (and others not so useful) #defines...
*/
#define CP_MIN(a, b) ((a) < (b) ? (a) : (b))
#define CP_MAX(a, b) ((a) > (b) ? (a) : (b))
// ---------------------------------------------------------------------------
/*
Use FastOffsetRect instead of CP_OffsetRect; this is slightly
faster (it doesn't incur the overhead of a function call).
This macro, and the ones like it below, will however
bloat your code slightly.
Unlike CP_OffsetRect, don't "pass" the address of the rect;
pass the rect itself...
*/
#define FastOffsetRect(r, x, y) \
r.top += y; \
r.left += x; \
r.bottom += y; \
r.right += x
// ---------------------------------------------------------------------------
/*
Again, like FastOffsetRect, use this for
speedier results. Slightly better than
UnionRect.
*/
#define FastUnionRect(s, d, u) \
u.top = CP_MIN(s.top, d.top); \
u.left = CP_MIN(s.left, d.left); \
u.bottom = CP_MAX(s.bottom, d.bottom); \
u.right = CP_MAX(s.right, d.right)
// ---------------------------------------------------------------------------
#define FastOffsetPt(pt, x, y) \
(CP_Point)pt.hv.v += y; \
(CP_Point)pt.hv.h += x
// ---------------------------------------------------------------------------
#endif // CP_UTILS_H_